using ReflectionStudio.Core.Events;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Threading;
using System.Windows;
using WPFExcelReport.Helpers;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
namespace WPFExcelReport
{
    public partial class VDRAUFTR
    {
        private string _PREFIX = ""; public string PREFIX { get { return _PREFIX; } set { _PREFIX = value; OnPropertyChanged("PREFIX", value); } }
        private string _DESTFOLDER = " "; public string DESTFOLDER { get { return _DESTFOLDER; } set { _DESTFOLDER = value; OnPropertyChanged("DESTFOLDER", value); } }
 
        private int _COPYS = 1; public int COPYS { get { return _COPYS; } set { _COPYS = value; OnPropertyChanged("COPYS", value); } }
        private string _PrintType = "OpenExcel"; public string PrintType { get { return _PrintType; } set { _PrintType = value; OnPropertyChanged("PrintType", value); } }
        private ITXEXRPT _ITXEXRPT;
        public ITXEXRPT ITXEXRPT
        {
            get 
            {
                if(_ITXEXRPT == null)
                {
                    _ITXEXRPT = new ITXEXRPT();
                    _ITXEXRPT.Root = "C:\\IntexReport";
                    _ITXEXRPT.strCompany = app.company;
                    _ITXEXRPT.PrintType = PrintType;
                }
                return _ITXEXRPT;
            }
            
        }
       public string DocType
        {
            get 
            {
                return ITXEXRPT.DocType;
            }
            set
            {
                ITXEXRPT.DocType = value;
            }
        }
        public void PRINT(DataSet Set)
        {
            try
            {
                ITXEXRPT.dsSource = Set;
                string filename = ITXEXRPT.WriteExcelReport(PrintType);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void PRINT(DataSet Set,bool IsQuiet)
        {
            try
            {
                ITXEXRPT.dsSource = Set;
                if (IsQuiet)
                {
                    SILENTPRINT();
                }
                else
                {
                    PRINT(Set);
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        Thread pr;
        public void SILENTPRINT()
        {
            pr = new Thread(StartPrint);
            pr.IsBackground = true;
            pr.ApartmentState = ApartmentState.STA;
            pr.Start();
        }
        public void StartPrint()
        {
            
            string filename = ITXEXRPT.WriteExcelReport(PrintType);
        }
    }
}
